package com.tangruojie;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.tangruojie.dao.BookDao;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.sql.DataSource;
import java.sql.SQLException;

public class App {
    public static void main(String[] args) throws SQLException {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        DataSource dataSource = (DataSource) ctx.getBean("dataSource");
        System.out.println(dataSource);

        ComboPooledDataSource comboPooledDataSource = (ComboPooledDataSource) ctx.getBean("comboPooledDataSource");
        System.out.println(comboPooledDataSource);

        BookDao bookDao = (BookDao) ctx.getBean("bookDao");
        bookDao.save();
    }
}
